#include "cs8doublespinbox.h"

#include <QKeyEvent>
#include <QDebug>
#include <QCoreApplication>
cs8DoubleSpinBox::cs8DoubleSpinBox(QWidget *parent) :
    QDoubleSpinBox(parent)
{
}

void cs8DoubleSpinBox::keyPressEvent(QKeyEvent *event)
{
    switch (event->key ())
    {
    case Qt::Key_Return:
    {
        qDebug() << "cs8DoubleSpiBox: Key_Return";
        QKeyEvent event(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier);
        QDoubleSpinBox::keyPressEvent(&event);
        //emit keypress(Qt::Key_Right);
        break;
    }
    case Qt::Key_Up:
    case Qt::Key_Down:
    case Qt::Key_Right:
    case Qt::Key_Left:
    {
        qDebug() << "cs8DoubleSpiBox: Cursor Key";
        QKeyEvent event_(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier);
        QDoubleSpinBox::keyPressEvent(&event_);
        emit keypress(event->key ());
        //QCoreApplication::postEvent (parent (),event);
        //event->accept ();
        break;
    }
    default:
    {
        QDoubleSpinBox::keyPressEvent (event);
        break;
    }
    }
}
